package reflect;

import java.io.File;
import java.lang.reflect.Field;

/*
*访问私有属性
* */
public class ReflectDemo9 {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Teacher");
        Object obj = cls.newInstance();

        Field field =cls.getDeclaredField("gender");
        field.setAccessible(true);
        field.set(obj,"男");
        System.out.println(field);
    }
}
